/**
 * GoodsType 业务逻辑实现类
 * @author WangXinLei
 * @date 2015-01-07
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.GoodsType;
import com.chnbst.bstyun.model.vo.GoodsTypeTreeVo;
import com.chnbst.bstyun.model.vo.GoodsTypeVo;
import com.chnbst.bstyun.service.GoodsTypeService;

@Transactional
@Service
public class GoodsTypeServiceImpl  extends BaseService implements GoodsTypeService {

	//命名空间
	private final static String nameSpace = "com.chnbst.bstyun.mapper.GoodsTypeMapper";
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<GoodsType> selectGoodsType() {
		return (List<GoodsType>)DaoHelper.list(nameSpace, "selectGoodsType", null);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	public int selectCount(String typeId) {
		return DaoHelper.count(nameSpace, "selectCount", typeId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<GoodsTypeTreeVo> selectGoodsTypeGrid(Map<String, Object> map) {
		return (List<GoodsTypeTreeVo>)DaoHelper.list(nameSpace, "selectGoodsTypeGrid", map);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<GoodsTypeVo> selectGridByCondition(Map<String, Object> map) {
		return (List<GoodsTypeVo>)DaoHelper.list(nameSpace, "selectGridByCondition", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public GoodsTypeVo selectGoodsTypeVoInfo(String typeId) {
		return (GoodsTypeVo) DaoHelper.query(nameSpace, "selectGoodsTypeVoInfo", typeId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertGoodsType(GoodsType goodsType) {
		return DaoHelper.insert(nameSpace, "insertGoodsType", goodsType);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateGoodsType(GoodsType goodsType) {
		return DaoHelper.insert(nameSpace, "updateGoodsType", goodsType);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public GoodsType changeGoodsTypeNum(String goodsTypeNum) {
		return (GoodsType) DaoHelper.query(nameSpace, "changeGoodsTypeNum", goodsTypeNum);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<GoodsType> selectProductsByTypeId(String typeId) {
		return (List<GoodsType>)DaoHelper.list(nameSpace, "selectProductsByTypeId", typeId);
	}

	@Override
	public boolean deleteByTypeId(GoodsType goodsType) {
		return DaoHelper.update(nameSpace, "deleteByTypeId", goodsType);
	}

	@Override
	public List<GoodsType> selectP() {
		// TODO Auto-generated method stub
		return (List<GoodsType>) DaoHelper.list(nameSpace, "selectP", null);
	}

	@Override
	public List<GoodsType> selectC(String pid) {
		// TODO Auto-generated method stub
		return (List<GoodsType>) DaoHelper.list(nameSpace, "selectC", pid);
	}
	
}
